/**
 * 功能说明：用户列表模块。
 */
import { fetchUsers } from '../../api/users'
import { CONFIG } from '../../config'

export default {
  namespaced: true,
  state: { items: [], total: 0, page: 1, pageSize: CONFIG.PAGE_SIZE },
  mutations: {
    setList(state, { items, total }) { state.items = items; state.total = total },
    setPage(state, p) { state.page = p }
  },
  actions: {
    async load({ commit, state }) {
      const res = await fetchUsers(state.page, state.pageSize)
      commit('setList', { items: res.items, total: res.total })
    }
  }
}

